package com.lilingguo.easyserver.listener;

import com.lilingguo.easyserver.container.Container;
import com.lilingguo.easyserver.pojo.Persistence;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 监听类
 * 在项目启动时，初始化容器
 *
 * @Author: 黎铃果
 * @Date: 2020/05/28 16:40
 */
@Component
public class EasyServerApplicationRunner implements ApplicationRunner {

    @Autowired
    private Container container;
    @Autowired
    private Persistence persistence;

    @Override
    public void run(ApplicationArguments args) {
        container.init();
        if (persistence != null) {
            persistence.load(container);
        }
    }
}
